<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Xppass Administrator's Control Panel</title>
<LINK href="<?php echo $www_site_url?>/public/yav-style.css" type=text/css rel=stylesheet>
<script src="<?php echo $www_site_url?>/public/js/common.js" type="text/javascript"></script>
<script src="<?php echo $www_site_url?>/public/js/ajax.js" type="text/javascript"></script>
<script src="<?php echo $www_site_url?>/public/js/PCASClass.js"></script>



<script>
function getBrand(c_id){
	if(c_id==''){
		var selobj = $('store_container');
		for(var i in selobj.options){
			selobj.options[i] = null;
		}
		selobj.options[0] = new Option('--', '');
		return ;
	}
	var url = "<?php echo $www_site_url?>/admin.php?action=corporation&view=ajaxbrand&c_id="+c_id;

	mini.ajax.get(url, function(r){

		var r = eval('(' + r + ')');

		if(r.s==200){
			var obj = eval('(' + r.d + ')');
			var selobj = $('brand_container');
			for(var i in obj){
				//if(i==0) selobj.options[0] = new Option(obj[i].cs_name, obj[i].cs_id) //replace 1st option with a new one
				selobj.options[i]=new Option(obj[i].b_name,obj[i].b_id) //add a new option to the end of SELECT
			}

		}
		if(r.s==400){
			$('msg').innerHTML = r.m;
		}
	});

	return false;
}
function checkOnSubmit(formName) {

	var url = "<?php echo $www_site_url?>/admin.php";
	var params = mini.form.serialize($(formName));

	mini.ajax.post(url, function(r){
		var r = eval('(' + r + ')');

		if(r.s==200){
			window.location.href = r.d;
		}
		if(r.s==400){
			$('msg').innerHTML = r.m;
		}
	}, params);

	return false;

}

</script>
</head>
<body><div id="append"></div>
<div id="msg" style="color:red;text-align:center"></div>
	<div class="container">

		<div class="hastabmenu">
				<ul class="tabmenu">
					<li id="addcorporationbtn" class="tabcurrent"><a href="#"><?php echo lang('add_store')?></a></li>
				</ul>
				<div id="addcorporationdiv" class="tabcontentcur" style="width:80%">
					<form id="addcorporationform" name="addcorporationform" action="<?php echo $www_site_url?>/admin.php" method="post" onsubmit="return checkOnSubmit('addcorporationform');" >
					<input type="hidden" name="action" value="corporation">
					<input type="hidden" name="op" value="updatestore">
					<input type="hidden" name="cs_id" value="<?php echo $cs_id?>">

					<table width="100%">
						<tr>
							<td width="10%"><?php echo lang('cs_name')?>:</td>
							<td><input type="text" name="cs_name" class="textfield" style="width:500px;" value="<?php echo $store['cs_name']?>"/> *<input type="button" value="Split" onclick="document.addcorporationform.cs_name.value+='&lt;!--!--&gt;';"></td>

							</tr>
						<tr>
							<td width="10%"><?php echo lang('cs_abbr')?>:</td>
							<td><input type="text" name="cs_abbr" class="textfield" value="<?php echo $store['cs_abbr']?>"/> *</td>

							</tr>

						<tr>
							<td><?php echo lang('cs_address')?>:</td>
							<td><input type="text" name="cs_address"  class="textfield"  style="width:500px;"  value="<?php echo $store['cs_address']?>"/> <input type="button" value="Split" onclick="document.addcorporationform.cs_address.value+='&lt;!--!--&gt;';"></td>
							</tr>

						<tr>
							<td><?php echo lang('cs_corpration')?>:</td>
							<td><select name="c_id" onchange="getBrand(this.options[this.selectedIndex].value);">
							<?php foreach ($corps as $v){?>
							<option value="<?php echo $v['c_id'];?>" <?php if($v['c_id']==$store['c_id']) echo "selected";?>><?php echo $v['c_initial']." ". splitx($v['c_title']);?></option>
							<?php } ?>
							</select></td>
							</tr>
							<tr>
							<td><?php echo lang('b_name')?>:</td>
							<td><select id="brand_container" name="b_id" onchange="getStore(this.options[this.selectedIndex].value);">
							<option value="">--</option>
							<?php foreach ($brands as $v){?>
							<option value="<?php echo $v['b_id'];?>" <?php if($v['b_id']==$store['b_id']) echo "selected";?>><?php echo splitx($v['b_name']);?></option>
							<?php } ?>
							</select></td>
						</tr>
							<tr>
							<td><?php echo lang('c_storesize')?>:</td>
							<td><select name="cs_size">
							<option value="0">--</option>
							<?php
foreach ($GLOBALS['gCompanysize'] as $k=>$v){
	?>
							<option value="<?php echo $k;?>" <?php if($store['cs_size']==$k) echo "selected"?>><?php echo $v?></option>
<?php
}
?>

							</select>
							</td>
						</tr>
						<tr>
							<td><?php echo lang('city_district')?>:</td>
							<td>
							<select name="cs_province"></select><select name="cs_city"></select><select name="cs_district"></select>
							</td>
						</tr>
						<tr>
							<td><?php echo lang('c_phone')?>:</td>
							<td><input type="text" name="cs_phone" value="<?php echo $store['cs_phone']?>" class="textfield"/></td>
						</tr>
						<tr>
							<td>分店顺序：</td>
							<td><input type="text" name="cs_order" size="3" value="<?php echo $store['cs_order']?>" class="textfield" /></td>
						</tr>
						<tr>
							<td><?php echo lang('a_desc')?>:</td>
							<td><textarea type="text" name="cs_desc" rows="10" style="width:500px"  class="textfield"><?php echo splitx($store['cs_desc'])?></textarea><input type="button" value="Split" onclick="document.addcorporationform.cs_desc.value+='&lt;!--!--&gt;';"></td>
						</tr>
						<tr>
							<td><?php echo lang('a_demand')?>:</td>
							<td><textarea type="text" name="cs_demand" rows="10" style="width:500px"  class="textfield"><?php echo splitx($store['cs_demand'])?></textarea><input type="button" value="Split" onclick="document.addcorporationform.cs_demand.value+='&lt;!--!--&gt;';"></td>
						</tr>
						<tr>
							<td><?php echo lang('a_quiz')?>:</td>
							<td>
							<div>格式说明,每一行输入一个测试题目。格式为 title:问题标题|A:答案|B:答案|C:答案|D:答案|answer:D</div>
							<textarea type="text" name="cs_quiz" rows="10" style="width:500px"  class="textfield"><?php if($store['cs_quiz']) echo splitx($store['cs_quiz']); else echo "title:去肯德基一定要点的是什么？|A:薯条|B:鸡翅|C:汉堡|D:可乐|answer:B
title:用餐结束之后不要忘记什么？|A:买单|B:刷卡|C:要发票|D:贵重物品|answer:C"; ?></textarea><input type="button" value="Split" onclick="document.addcorporationform.cs_quiz.value+='&lt;!--!--&gt;';">
							</td>
						</tr>
						<tr>
							<td><?php echo lang('a_reim')?>:</td>
							<td><input type="text" name="cs_reim" value="<?php echo splitx($store['cs_reim'])?>"  class="textfield"/>元</td>
						</tr>
						<tr>
							<td><?php echo lang('disabled');?>:</td>
							<td>
								<input type="radio" name="setdisable" value="0" <?php if($store['disabled'] == 0) echo "checked";?> /> 启用
								<input type="radio" name="setdisable" value="1" <?php if($store['disabled'] == 1) echo "checked";?> /> 不启用
							</td>
						</tr>
						<tr>
							<td colspan="2"><input type="submit" value="<?php echo lang('submit')?>" class="button"/></td>
						</tr>
					</table>
					</form>

				</div>
		</div>
</div>
<script>
new PCAS("cs_province","cs_city","cs_district","<?php echo $store['cs_province']?>","<?php echo $store['cs_city']?>","<?php echo $store['cs_district']?>");

</script>
</body>
</html>